package com.atguigu.Util;

import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;


import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;

/**
 * @author hjy
 * @create 2023/3/14 19:01
 */
public class KeywordUtil {
    public static List<String> getIkWordList(String value) throws IOException {
        ArrayList<String> wordList = new ArrayList<>();
        IKSegmenter ikSegmenter = new IKSegmenter(new StringReader(value), false);

        Lexeme next = ikSegmenter.next();
        while (next !=null){
            String word = next.getLexemeText();
            wordList.add(word);
           next=ikSegmenter.next();
        }
        return wordList;
    }
}
